//
//  GRStoreAction.m
//  YC_GRice
//
//  Created by luojinrong11 on 2018/8/28.
//  Copyright © 2018年 YeCai. All rights reserved.
//

#import "GRStoreAction.h"

@implementation GRStoreAction
+(void)getStoreDetailWithStoreId:(NSInteger)storeId ParamerDic:(NSDictionary *)paramerDic ComplectionHander:(RequestBlock)complectionHander{
    NSString * url = [NSString stringWithFormat:@"%@onePay/%ld",GRDeliveryAPI,storeId];
    [RequestManager TouristsRequestWithURLString:url Method:GR_POST Paramers:paramerDic completionHandler:complectionHander ];
}

+(void)getGoodDetailPageWithGoodId:(NSInteger)goodId ParamerDic:(NSDictionary *)paramerDic IsBargain:(BOOL)isbargain ComplectionHander:(RequestBlock)complectionHander {
    NSString * url;
    if (isbargain) {
        url =  [NSString stringWithFormat:@"%@onePayDiscount/detail/%ld",GRDeliveryAPI,goodId];
    }else{
      url = [NSString stringWithFormat:@"%@onePay/discount/%ld",GRDeliveryAPI,goodId];
    }
    
    [RequestManager TouristsRequestWithURLString:url Method:isbargain?GR_GET: GR_POST Paramers:paramerDic completionHandler:complectionHander ];
    
}

+(void)getdiscountAnalyOrderWithGoodId:(NSInteger)goodId  isOrder:(BOOL)isOrder ComplectionHander:(RequestBlock)complectionHander{
    
    NSString * url = [NSString stringWithFormat:@"%@onePayDiscountOrder/analyOrder/%ld%@",GRDeliveryAPI,goodId,isOrder?@"?type=order":@""];
    [RequestManager MembershipRequestWithURLString:url Method:GR_GET
                                          Paramers:nil completionHandler:complectionHander];
}

+(void)createOrderWithDic:(NSDictionary*)paramerDic ComplectionHander:(RequestBlock)complectionHander{
    NSString * url = [NSString stringWithFormat:@"%@onePayDiscountOrder/placeOrder",GRDeliveryAPI];
    [RequestManager MembershipRequestWithURLString:url Method:GR_POST Paramers:paramerDic completionHandler:complectionHander];
    
}
+(void)readyPayTheBillWithStoreId:(NSInteger)storeId ComplectionHander:(RequestBlock)complectionHander{
    NSString * url = [NSString stringWithFormat:@"%@onePayOrder/readyPayTheBillNew/%ld",GRDeliveryAPI,(long)storeId];
    [RequestManager MembershipRequestWithURLString:url Method:GR_POST Paramers:nil completionHandler:complectionHander];
}
+(void)payOrder:(NSDictionary * )dic ComplectionHander:(RequestBlock)complectionHander{
    NSString * url = [NSString stringWithFormat:@"%@onePayOrder/create",GRDeliveryAPI];
    [RequestManager MembershipRequestWithURLString:url Method:GR_POST Paramers:dic completionHandler:complectionHander];
}

+(void)getpayDetails:(NSInteger)orderId ComplectionHander:(RequestBlock)complectionHander{
    NSString * url = [NSString stringWithFormat:@"%@onePayOrder/details/%ld",GRDeliveryAPI,orderId];
    [RequestManager MembershipRequestWithURLString:url Method:GR_POST Paramers:nil completionHandler:complectionHander];
}
+(void)getNewsDetail:(NSInteger)type NewsId:(NSInteger)newsId ComplectionHander:(RequestBlock)complectionHander{
    NSString * url = [NSString stringWithFormat:@"%@onePay/news/%ld/%ld",GRDeliveryAPI,type,newsId];
      CLLocationCoordinate2D location =  [GRLocationManager defaultManager].coordinate;
    NSDictionary * dic = @{
                           @"lantitude":@(location.latitude),
                           @"longitude":@(location.longitude),
                           @"profileId":[GRUserBasisInfo BasisID]
                           };
    [RequestManager TouristsRequestWithURLString:url Method:GR_POST Paramers:dic completionHandler:complectionHander];
}

+(void)getRiceOrderList:(NSDictionary *)paramDic ComplectionHander:(RequestBlock)complectionHander{
    NSString *url = [NSString stringWithFormat:@"%@onePayDiscountOrder/discountOrderList",GRDeliveryAPI];
    [RequestManager MembershipRequestWithURLString:url Method:GR_POST Paramers:paramDic completionHandler:complectionHander];
}

+(void)getRiceOrderDetailPage:(NSInteger )orderId ComplectionHander:(RequestBlock)complectionHander{
    NSString *url = [NSString stringWithFormat:@"%@onePayDiscountOrder/discountOrderDetails/%ld",GRDeliveryAPI,orderId];
    [RequestManager MembershipRequestWithURLString:url Method:GR_POST Paramers:nil completionHandler:complectionHander];
}

+(void)RiceOrderReturnMoney:(NSDictionary *)paramDic ComplectionHander:(RequestBlock)complectionHander{
    NSString *url = [NSString stringWithFormat:@"%@onePayDiscountOrder/refund",GRDeliveryAPI];
    [RequestManager MembershipRequestWithURLString:url Method:GR_POST Paramers:paramDic completionHandler:complectionHander];
    
}
+(void)RiceCancleOrder:(NSDictionary*)dic ComplectionHander:(RequestBlock)complectionHander{
    
    NSString *url = [NSString stringWithFormat:@"%@onePayDiscountOrder/cancel",GRDeliveryAPI];
    [RequestManager MembershipRequestWithURLString:url Method:GR_POST Paramers:dic completionHandler:complectionHander];
}
+(void)riceOrderComment:(NSDictionary *)dic ComplectionHander:(RequestBlock)complectionHander{
    NSString * url = [NSString stringWithFormat:@"%@onePay/comment",GRDeliveryAPI];
    [RequestManager MembershipRequestWithURLString:url Method:GR_POST Paramers:dic completionHandler:complectionHander];
}

+(void)addFavorite:(NSInteger)favoriteId FavoriteType:(NSString *)type  ComplectionHander:(RequestBlock)complectionHander{
    NSString * url = [NSString stringWithFormat:@"%@OnePayFavorite/add/%ld/%@",GRDeliveryAPI,favoriteId,type];
    [RequestManager MembershipRequestWithURLString:url Method:GR_POST Paramers:nil completionHandler:complectionHander];
    
}

@end
